package com.hello.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hello.common.log.annotation.Log;
import com.hello.common.log.enums.BusinessType;
import com.hello.common.security.annotation.RequiresPermissions;
import com.hello.system.domain.Reports;
import com.hello.system.service.IReportsService;
import com.hello.common.core.web.controller.BaseController;
import com.hello.common.core.web.domain.AjaxResult;
import com.hello.common.core.utils.poi.ExcelUtil;
import com.hello.common.core.web.page.TableDataInfo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * 用户举报投诉Controller
 * 
 * @author hello
 * @date 2025-10-29
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/reports")
public class ReportsController extends BaseController
{
    private final IReportsService reportsService;

    /**
     * 查询用户举报投诉列表
     */
    @RequiresPermissions("system:reports:list")
    @GetMapping("/list")
    public TableDataInfo list(Reports reports)
    {
        startPage();
        List<Reports> list = reportsService.selectReportsList(reports);
        return getDataTable(list);
    }

    /**
     * 导出用户举报投诉列表
     */
    @RequiresPermissions("system:reports:export")
    @Log(title = "用户举报投诉", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Reports reports)
    {
        List<Reports> list = reportsService.selectReportsList(reports);
        ExcelUtil<Reports> util = new ExcelUtil<Reports>(Reports.class);
        util.exportExcel(response, list, "用户举报投诉数据");
    }

    /**
     * 获取用户举报投诉详细信息
     */
    @RequiresPermissions("system:reports:query")
    @GetMapping(value = "/{reportId}")
    public AjaxResult getInfo(@PathVariable("reportId") Long reportId)
    {
        return success(reportsService.selectReportsByReportId(reportId));
    }

    /**
     * 新增用户举报投诉
     */
    @RequiresPermissions("system:reports:add")
    @Log(title = "用户举报投诉", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Reports reports)
    {
        return toAjax(reportsService.insertReports(reports));
    }

    /**
     * 修改用户举报投诉
     */
    @RequiresPermissions("system:reports:edit")
    @Log(title = "用户举报投诉", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Reports reports)
    {
        return toAjax(reportsService.updateReports(reports));
    }

    /**
     * 删除用户举报投诉
     */
    @RequiresPermissions("system:reports:remove")
    @Log(title = "用户举报投诉", businessType = BusinessType.DELETE)
	@DeleteMapping("/{reportIds}")
    public AjaxResult remove(@PathVariable Long[] reportIds)
    {
        return toAjax(reportsService.deleteReportsByReportIds(reportIds));
    }
}
